package flc.ast.utils;

import android.content.Context;

import androidx.room.Database;
import androidx.room.Room;
import androidx.room.RoomDatabase;

import flc.ast.bean.OvertimeBean;
import flc.ast.bean.WorkTimeBean;


@Database(entities = {OvertimeBean.class, WorkTimeBean.class}, version = 2, exportSchema = false)
public abstract class MyDatabase extends RoomDatabase {
    //暴露Dao
    public abstract OvertimeDao getOvertimeDao();
    public abstract WorkTimeDao getWorkTimeDao();

    private static MyDatabase INSTANCE;

    public static synchronized MyDatabase getInstance(Context context) {
        if (INSTANCE == null) {
            INSTANCE = Room.databaseBuilder
                            (context.getApplicationContext(),
                                    MyDatabase.class, "my_database")
                    .allowMainThreadQueries()
                    .build();
        }
        return INSTANCE;
    }
}

